package com.tianbao54.kotlin_01

open class MyParent {

    open var name = "parent"
}

class MyChild : MyParent() {

    override var name = "child"
}

class MyChild2(override var name: String) : MyParent() {

}

open class MyParent3 {

    open fun method () {
        println("parent method")
    }

    open val name: String get() = "parent"
}

/**
 *  val override val
 *  var override val
 *  val not override var
 *  var 拥有 get and set 方法，而 val 只有 get 方法。
 */
class MyChild3: MyParent3() {

    override fun method() {
        super.method()
        println("child method")
    }

    override val name: String get() = super.name + " and child"
}

fun main(args: Array<String>) {

    var myChild = MyChild()
    println(myChild.name)
    println("---------------")
    var myChild3 = MyChild3()
    println(myChild3.name)
}